import request from './request'

// 登录方法
export function doUserLogin(data) {
    return request({
        url: '/user/login',
        method: 'post',
        data: {...data}
    })
}

// 获取用户详细信息
export function doGetUserInfo() {
    return request({
        url: '/user/getInfo',
        method: 'get'
    })
}

// 退出方法
export function doUserLogout() {
    return request({
        url: '/user/logout',
        method: 'post'
    })
}

//注册
export function doUserRegister(data) {
    return request({
        url: '/user/register',
        method: 'post',
        data: {...data}
    })
}

export function doGetUserQuestion(data){
    return request({
        url: '/user/forgetGetQuestion',
        method: 'post',
        data: {...data}
    })
}

export function doUserCheckAnswer(data){
    return request({
        url: '/user/forgetCheckAnswer',
        method: 'post',
        data: {...data}
    })
}

export function doUserForgetRestPassword(data){
    return request({
        url: '/user/forgetResetPassword',
        method: 'post',
        data: {...data}
    })
}

export function doGetProductDefaultImg(){
    return request({
        url: '/product/defaultImg',
        method: 'post'
    })
}

export function doAddCart(data){
    return request({
        url: '/cart/add',
        method: 'post',
        data: {...data}
    })
}

export function doCartList(){
    return request({
        url: '/cart/list',
        method: 'post'
    })
}

export function doGetCartProductCount(){
    return request({
        url: '/cart/getCartProductCount',
        method: 'post'
    })
}
export function doCartUpdate(data){
    return request({
        url: '/cart/update',
        method: 'post',
        data: {...data}
    })
}

export function doCartSelectOrUnSelect(params){
    return request({
        url: '/cart/selectOrUnSelect/' + params.productId + "/" + params.checked,
        method: 'post',
        data: {...params}
    })
}

export function doCartDeleteProduct(params){
    return request({
        url: '/cart/deleteProduct/' + params.productIds,
        method: 'post',
        data: {...params}
    })
}

export function changeAllSelectedStatus(params){
    return request({
        url: '/cart/changeAllSelectedStatus/' + "/" + params.checked,
        method: 'post'
    })
}

export function getCurrentOrder(data){
    return request({
        url: '/order/getCurrentOrder',
        method: 'get'
    })
}


export function createOrder(data){
    return request({
        url: '/order/create',
        method: 'post',
        data: data
    })
}

export function cancelOrder(params){
    return request({
        url: '/order/cancel/' + params.orderNo,
        method: 'get'
    })
}

export function getDetailByOrderNo(params){
    return request({
        url: '/order/detail/' + params.orderNo,
        method: 'get'
    })
}


export function listOrder(params){
    return request({
        url: '/order/list/' + params.pageNum + "/" + params.pageSize,
        method: 'get'
    })
}

export function listShipping(params){
    return request({
        url: '/shipping/list/' + params.pageNum + "/" + params.pageSize,
        method: 'get'
    })
}

export function getShippingById(params){
    return request({
        url: `/shipping/select/${params.id}`,
        method: 'get'
    })
}

export function addShipping(data){
    return request({
        url: '/shipping/add',
        method: 'post',
        data: data
    })
}

export function delShippingById(params){
    return request({
        url: `/shipping/delete/${params.id}`,
        method: 'post',
    })
}

export function updateShipping(data){
    return request({
        url: '/shipping/update',
        method: 'post',
        data: data
    })
}

export function updateDefaultShipping(shippingId){
    return request({
        url: `/shipping/updateDefaultShipping/${shippingId}`,
        method: 'post'
    })
}